package edu.qqilin.springframework.beans.factory.support;

import edu.qqilin.springframework.core.io.DefaultResourceLoader;
import edu.qqilin.springframework.core.io.ResourceLoader;

/**
 * Description: 读取器的抽象基类。
 * <p>
 * 实现了通用的资源加载逻辑（持有 {@link ResourceLoader}），把具体的解析工作留给子类。
 *
 * @author qqilin1213
 * @version 1.0
 * @date 2025/11/24 15:15
 */
public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader{
    private final BeanDefinitionRegistry registry;

    private final ResourceLoader resourceLoader;

    protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry) {
        this(registry, new DefaultResourceLoader());
    }

    public AbstractBeanDefinitionReader(BeanDefinitionRegistry registry, ResourceLoader resourceLoader) {
        this.registry = registry;
        this.resourceLoader = resourceLoader;
    }

    @Override
    public BeanDefinitionRegistry getRegistry() {
        return registry;
    }

    @Override
    public ResourceLoader getResourceLoader() {
        return resourceLoader;
    }
}
